package cn.tedu.mvcboot01.controller;

import cn.tedu.mvcboot01.pojo.dto.BmiDTO;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class BMIController {
    //    @RequestMapping("/bmi")
//    @ResponseBody
//    public String bmiControl(double height,double weight){
//        double result=weight/(height*height);
//        if (result < 18.5) {
//            return "偏瘦";
//        }
//        if (result < 24) {
//            return "正常";
//        }
//        if (result < 27) {
//            return "微胖";
//        }
//        return "该减肥了";
//    }
    @RequestMapping("/bmi")
    @ResponseBody
    public String bmiControl(BmiDTO bmiDTO) {
        double height = bmiDTO.getHeight();
        double weight = bmiDTO.getWeight();
        double result = weight / (height * height);
        if (result < 18.5) {
            return "偏瘦";
        }
        if (result < 24) {
            return "正常";
        }
        if (result < 27) {
            return "微胖";
        }
        return "该减肥了";
    }
}
